Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize when colliders are regenerated for imported meshes #88045

Merged

Conversation

Malcolmnixon
Copy link
Contributor

This pull request fixes unnecessary regeneration of collision shapes in the import dialog. The old logic recalculated the colliders for every mesh in the model - including for meshes that did not have physics colliders enabled, and for meshes with existing colliders whose settings had not been modified.

This was not a problem for simple models; however @yythlj encountered this attempting to import the shop_house.zip model which consists of:

  • 68513 vertices
  • 56289 triangles
  • 1176 discrete objects/meshes

Changing physics settings on any mesh resulted in calculating colliders for all 1176 meshes, which takes so long I gave up trying to measure it. This behavior is now modified to only calculate the collider for a mesh under the following circumstances:

  1. The collider is being made visible (ensures previously-enabled colliders are calculated for preview in the import dialog).
  2. The currently selected mesh collider settings have been modified triggering a regeneration with different collision settings.

For the shop_house model described above; if collision happened to be enabled for all 1176 meshes there would still be an unavoidable enormous delay on opening the import dialog so the collider meshes could be calculated for preview.

The following video demonstrates opening the import settings on the shop_house model with a few colliders enabled, then toggling the collider-generation on a few meshes and re-importing.

2024-02-06.22-58-29.mp4

Copy link
Member

@fire fire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, we probably still want to profile and optimize colliders for all 1176 meshes since there is a way to automatically generate all colliders, but this is an improvement.

@akien-mga akien-mga merged commit 5c1b926 into godotengine:master Mar 9, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants